// coding: utf8
// datetime: 2021-04-24
// 题目地址: https://leetcode-cn.com/problems/combination-sum-iv/
package main

import "fmt"

func combinationSum4(nums []int, target int) int {
	var count = []int{0}
	dfs(nums, 0, target, count)
	return count[0]
}

func dfs(nums [] int, sum int, target int, count []int)  {
	if sum == target{
		count[0] += 1
		return
	}
	if sum > target{
		return
	}
	for _, val := range nums {
		sum += val
		dfs(nums, sum, target, count)
		sum -= val
	}
}

func main() {
	var nums = []int{1,2,3}
	fmt.Println(combinationSum4(nums, 32))
}